package com.tanhua.server.controller;

import com.tanhua.model.vo.VoiceVo;
import com.tanhua.server.service.VoicesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

/**
 * 桃花传音控制层
 * @author LiuKeLin
 * @title: ReceivingVoiceController
 * @projectName tanhua-practice
 * @description: TODO
 * @date 2022/2/219:06
 */
@RestController
@RequestMapping("/peachblossom")
public class VoiceController {

    @Autowired
    private VoicesService voicesService;

    //桃花传音-发送语音
    @PostMapping
    public ResponseEntity sendVoice(@RequestParam(value = "soundFile", required = false) MultipartFile voiceFile) {
        voicesService.sendVoice(voiceFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 接收语音
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public ResponseEntity peachblossom(){
        VoiceVo voiceVo =voicesService.findVoiceVo();
        return ResponseEntity.ok(voiceVo);
    }
}
